package com.example.learnvideo

import android.Manifest
import android.content.Intent
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import androidx.core.app.ActivityCompat
import com.example.learnvideo.base.BaseActivity
import com.example.learnvideo.bean.WifiConnect
import com.example.learnvideo.databinding.ActivityMainBinding
import com.example.learnvideo.ui.*

class MainActivity : BaseActivity<ActivityMainBinding>(),View.OnClickListener {

    override fun ActivityMainBinding.initBinding() {
        supportActionBar?.hide()
        btnCamera2Photo.setOnClickListener(this@MainActivity)
        btnCamera2Record.setOnClickListener(this@MainActivity)
        btnExoPlayer.setOnClickListener(this@MainActivity)
        btnVideoFrame.setOnClickListener(this@MainActivity)
        btnFloatWindow.setOnClickListener(this@MainActivity)
        btnScreenCapture.setOnClickListener(this@MainActivity)
        btnScreenRecord.setOnClickListener(this@MainActivity)
        btnWifiInfo.setOnClickListener(this@MainActivity)
        btnWifiConnect.setOnClickListener(this@MainActivity)
        btnBluetooth.setOnClickListener(this@MainActivity)

        //动态申请应用权限
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
            ActivityCompat.requestPermissions(this@MainActivity, arrayOf(
                Manifest.permission.WRITE_EXTERNAL_STORAGE,
                Manifest.permission.READ_EXTERNAL_STORAGE,
                Manifest.permission.ACCESS_FINE_LOCATION,
            ),1)
        }
    }

    override fun onClick(v: View?) {
        when(v?.id){
            mBinding.btnCamera2Photo.id -> startActivity(Intent(this,Camera2Photo::class.java))
            mBinding.btnCamera2Record.id -> startActivity(Intent(this,Camera2Record::class.java))
            mBinding.btnExoPlayer.id -> startActivity(Intent(this,ExoPlayerActivity::class.java))
            mBinding.btnVideoFrame.id -> startActivity(Intent(this,VideoFrameActivity::class.java))
            mBinding.btnFloatWindow.id -> startActivity(Intent(this,FloatWindowActivity::class.java))
            mBinding.btnScreenCapture.id -> startActivity(Intent(this,ScreenCaptureActivity::class.java))
            mBinding.btnScreenRecord.id -> startActivity(Intent(this,ScreenRecordActivity::class.java))
            mBinding.btnWifiInfo.id -> startActivity(Intent(this,WifiInfoActivity::class.java))
            mBinding.btnWifiConnect.id -> startActivity(Intent(this,WifiConnectActivity::class.java))
            mBinding.btnBluetooth.id -> startActivity(Intent(this,BluetoothActivity::class.java))

        }
    }

}